let app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    visit:false,
    order:false,
    chat:false
  },
  order_news:function(e){
    var that=this
    var value=0;
    if(e.detail.value==false)
    {
      value=0;
    }
    else
    {
      value=1;
    }
    wx.request({
      url: app.globalData.siteroot,
      data: {
        do:'System_noticeSwitch',
        staff_id:wx.getStorageSync('staff_bind_id'),
        notice_set_id:that.data.root.notice_set_id,
        type:'order_news',
        value:value
      },
      success: function(res) {
        
      }
    })
  },
  chat_news:function(e){
    var that=this
    var value=0;
    if(e.detail.value==false)
    {
      value=0;
    }
    else
    {
      value=1;
    }
    wx.request({
      url: app.globalData.siteroot,
      data: {
        do:'System_noticeSwitch',
        staff_id:wx.getStorageSync('staff_bind_id'),
        notice_set_id:that.data.root.notice_set_id,
        type:'chat_news',
        value:value
      },
      success: function(res) {
        
      }
    })
  },
  visit_news:function(e){
    var that=this
    var value=0;
    if(e.detail.value==false)
    {
      value=0;
    }
    else
    {
      value=1;
    }
    wx.request({
      url: app.globalData.siteroot,
      data: {
        do:'System_noticeSwitch',
        staff_id:wx.getStorageSync('staff_bind_id'),
        notice_set_id:that.data.root.notice_set_id,
        type:'visit_news',
        value:value
      },
      success: function(res) {
        
      }
    })
  },
  onLoad: function (options) {
    var that=this
    wx.request({
      url: app.globalData.siteroot,
      data: {
        do:'System_noticeSet',
        staff_id:wx.getStorageSync('staff_bind_id'),
      },
      success: function(res) {
        that.setData({
          root:res.data.info
        })
        console.log(res.data.info)
        if(res.data.info.visit_news==1)
        {
          that.setData({
            visit:true
          })
        }
        else
        {
          that.setData({
            visit:false
          })
        }
        if(res.data.info.order_news==1)
        {
          that.setData({
            order:true
          })
        }
        else
        {
          that.setData({
            order:false
          })
        }
        if(res.data.info.chat_news==1)
        {
          that.setData({
            chat:true
          })
        }
        else
        {
          that.setData({
            chat:false
          })
        }


      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})